﻿using System;
using System.Collections.Generic;

using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Text;

namespace WebUI.Reservation
{
    public partial class LookReservation : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                BindData();
            }
        }

        private void BindData()
        {
            Grid1.DataSource = BLL.OpenReservationMange.GetList(" confirmed = 'true'");
            Grid1.DataBind();
        }
        protected void bnSearch_Click(object sender, EventArgs e)
        {
            StringBuilder strWhere = new StringBuilder();
            if (dp_upDate.SelectedDate != null)
            {
                strWhere.AppendFormat(" date >= '{0}'", dp_upDate.SelectedDate);
            }
            if (dp_downDate.SelectedDate != null)
            {
                if (dp_upDate.SelectedDate != null)
                {
                    strWhere.Append(" AND ");
                }
                strWhere.AppendFormat(" date <= '{0}'", dp_downDate.SelectedDate);
            }
            System.Threading.Thread.Sleep(500);
            Grid1.DataSource = BLL.OpenReservationMange.GetList(strWhere.ToString());
            Grid1.DataBind();
        }
        protected void bnReset_Click(object sender, EventArgs e)
        {
            dp_downDate.SelectedDate = null;
            dp_upDate.SelectedDate = null;
            BindData();
        }
        protected void Grid1_PageIndexChange(object sender, ExtAspNet.GridPageEventArgs e)
        {
            Grid1.PageIndex = e.NewPageIndex;
        }
    }
}